import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'


import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', TreeTable)


//创建过滤器将秒数过滤为年月日，时分秒
Vue.filter('dateFormat', function (originVal) {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

// 接口基准地址：`https://www.liulongbin.top:8888/api/private/v1`
axios.defaults.baseURL = "https://www.liulongbin.top:8888/api/private/v1"
// 添加请求拦截
axios.interceptors.request.use(config => {
  config.headers.Authorization = sessionStorage.getItem("token")
  return config
})
// axios
import axios from 'axios'
Vue.prototype.$http = axios
Vue.config.productionTip = false

// ElementUI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

// Vant
import Vant from 'vant'
import 'vant/lib/index.css'
Vue.use(Vant)
// 懒加载
import {
  Lazyload
} from 'vant'
Vue.use(Lazyload)
Vue.use(Lazyload, {
  lazyComponent: true,
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')